package lab.gene.action;

import java.util.List;
import java.util.Date;

import com.opensymphony.xwork2.ActionSupport;

import lab.gene.pojo.GenePCR;
import lab.gene.pojo.GeneImageFile;

import lab.gene.service.impl.GenePCRServiceImpl;
import lab.gene.service.impl.GeneImageFileServiceImpl;

public class ViewGenePCRAction extends ActionSupport  {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private List<GeneImageFile> imageList = null;
	private String geneName = null;
	private GenePCR genePCR = null;
	private int sizeOne = 0;
	private String amplicon = null;
	private Date recordDate = null;
	private String comment = null;
	private String pcrType = null;
	private String stepType = null;
	
	public String execute() {
		System.out.println("View Gene PCR Action!");
		System.out.println(pcrType);
		System.out.println(stepType);
		String result = "successA";
		GenePCRServiceImpl service = new GenePCRServiceImpl();
		genePCR = service.getGenePCRByGeneName(geneName, pcrType, stepType);
		if(genePCR != null) {
			sizeOne = genePCR.getSize();
			amplicon = genePCR.getAmplicon();
			recordDate = genePCR.getRecordDate();
			comment = genePCR.getComment();
			pcrType = genePCR.getPcrType();
			System.out.println(pcrType);
		}
		//System.out.println("END View Gene PCR Action!");
		String formName = null;
		GeneImageFileServiceImpl fService = new GeneImageFileServiceImpl();	
		switch(stepType) {
		case "A":
			formName = "001/002 PCR (A)";
			imageList = fService.getGeneImageFilesByGeneNameAndFormName(geneName, formName);
			result = "successA";break;
		case "C":
			if(pcrType.equals("001026")) { 
				formName = "001/026 PCR (C)";
				imageList = fService.getGeneImageFilesByGeneNameAndFormName(geneName, formName);
				result = "successC1";
			}
			else{ 
				formName = "002/027 PCR (C)";
				imageList = fService.getGeneImageFilesByGeneNameAndFormName(geneName, formName);
				result = "successC2"; 
			}break;
		case "D":
			if(pcrType.equals("001028")){
				formName = "001/028 PCR (D)";
				imageList = fService.getGeneImageFilesByGeneNameAndFormName(geneName, formName);
				result = "successD1";
			}
			else{ 
				formName = "002/029 PCR (D)";
				imageList = fService.getGeneImageFilesByGeneNameAndFormName(geneName, formName);
				result = "successD2";
			} break;
		}
		System.out.println(result);
		return result;
	}
	public String getGeneName() {
		return geneName;
	}
	public void setGeneName(String geneName) {
		this.geneName = geneName;
	}
	public GenePCR getGenePCR() {
		return genePCR;
	}
	public void setGenePCR(GenePCR genePCR) {
		this.genePCR = genePCR;
	}
	public int getSizeOne() {
		return sizeOne;
	}
	public void setSizeOne(int sizeOne) {
		this.sizeOne = sizeOne;
	}
	public String getAmplicon() {
		return amplicon;
	}
	public void setAmplicon(String amplicon) {
		this.amplicon = amplicon;
	}
	public Date getRecordDate() {
		return recordDate;
	}
	public void setRecordDate(Date recordDate) {
		this.recordDate = recordDate;
	}
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	public String getPcrType() {
		return pcrType;
	}
	public void setPcrType(String pcrType) {
		this.pcrType = pcrType;
	}
	public String getStepType() {
		return stepType;
	}
	public void setStepType(String stepType) {
		this.stepType = stepType;
	}
	public List<GeneImageFile> getImageList() {
		return imageList;
	}
	public void setImageList(List<GeneImageFile> imageList) {
		this.imageList = imageList;
	}
	

}
